package com.gs.seckill.controller;

import com.gs.common.core.domain.AjaxResult;
import com.gs.seckill.service.SecKillService;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class SecKillController {

  @Resource
  private SecKillService secKillService;


  @GetMapping("/seckill/FlashSale")
  public AjaxResult flashSale(@Param("secKillUserId") Long secKillUserId, @Param("secKillGoodsId") Long secKillGoodsId) {
    Boolean isCan = secKillService.flashSale(secKillUserId, secKillGoodsId);
    if (isCan) {
      return AjaxResult.success("不能购买");
    }
    return AjaxResult.success("成功购买");

  }

  @GetMapping("/findByStoreDesc")
  public AjaxResult findByStoreDesc() {
    secKillService.findByStoreDesc();
    return AjaxResult.success();
  }
}
